package application

import (
	"context"
	"zxstudy.com/domain/entity"
	"zxstudy.com/domain/repository"
)

type groupApp struct {
	repo repository.GroupRepository
}

type GroupApplication interface {
	Create(ctx context.Context, group *entity.Group) (*entity.Group, error)
	Get(ctx context.Context, id int) (*entity.Group, error)
	Groups(ctx context.Context) ([]*entity.Group, error)
}

func NewGroupApplication(repo repository.GroupRepository) *groupApp {
	return &groupApp{repo}
}

func (g *groupApp) Create(ctx context.Context, group *entity.Group) (*entity.Group, error) {
	return g.repo.Create(ctx, group)
}

func (g *groupApp) Get(ctx context.Context, id int) (*entity.Group, error) {
	return g.repo.Get(ctx, id)
}

func (g *groupApp) Groups(ctx context.Context) ([]*entity.Group, error) {
	return g.repo.Groups(ctx)
}